<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStoreCombinationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('store_combinations', function (Blueprint $table) {
            $table->id()->comment('拼团商品表');
            $table->integer('product_id')->comment('商品ID')->index();
            $table->integer('merchant_id')->comment('商户ID')->index();
            $table->string('recommend_image')->comment('推荐图');
            $table->string('title')->comment('拼团标题');
            $table->json('rotation_chart')->comment('轮播图');
            $table->integer('attribute')->default(0)->comment('活动状态 0:关闭 1:开启');
            $table->string('introduce')->comment('简介');
            $table->string('description')->nullable()->comment('内容');
            $table->timestamp('start_at')->comment('拼团开始时间');
            $table->timestamp('stop_at')->comment('拼团结束时间');
            $table->string('unit_name')->comment('单位名称');
            $table->decimal('price',10,2)->comment('价格');
            $table->integer('sort')->default(0)->comment('排序');
            $table->integer('sales')->default(0)->comment('销量');
            $table->integer('stock')->default(0)->comment('库存');
            $table->decimal('postage',10,2)->default(0.00)->comment('邮费');
            $table->integer('order_effective_at')->default(24)->comment('拼团订单有效时间 单位小时');
            $table->decimal('goods_cost')->default(0.00)->comment('原价');
            $table->integer('browse')->default(0)->comment('浏览量');
            $table->integer('temp_id')->default(0)->comment('运费模板ID');
            $table->decimal('weight',8,2)->default(0.00)->comment('重量');
            $table->decimal('volume',8,2)->default(0.00)->comment('体积');
            $table->integer('num')->comment('单次购买数量');
            $table->integer('once_num')->default(1)->comment('每个订单可购买数量');
            $table->integer('quota')->comment('限购总数');
            $table->integer('quota_show')->comment('限量总数显示');
            $table->integer('virtual')->nullable()->comment('虚拟成团百分比');
            $table->integer('people')->nullable()->comment('参与人数');
            $table->integer('group')->nullable()->comment('拼团人数');
            $table->integer('clusters')->nullable()->comment('成团数量');
            $table->tinyInteger('is_recommend')->default(0)->comment('是否推荐 【0:不推荐 1:推荐】');
            $table->tinyInteger('status')->default(0)->comment('商品状态 【0:不参与拼团 1:参与拼团】');
            $table->string('active_status')->default('noCompleted')->comment('状态 haveInHand：进行中 completed:已结束 noCompleted:未开始');
            $table->tinyInteger('merchant_use')->default(0)->comment('商户是否可用1可用0不可用');
            $table->tinyInteger('is_postage')->default(0)->comment('是否包邮1是0否');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('store_combinations');
    }
}
